package org.unt.mail.sender.other;

import java.net.URL;
import java.net.URLConnection;
import java.util.Properties;

import javax.mail.Message;
import javax.mail.Multipart;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;

//import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;

public class Test {

    public static void main(String[] args) throws Exception {

        System.setProperty("http.proxyHost", "ar.internet.inetpsa.com");
        System.setProperty("http.proxyPort", "8081");

        URL url = new URL("http://www.clarin.com");
        URLConnection uc = url.openConnection();
        //String encoded = new String(Base64.encode(new String("u336654:canibal8").getBytes()));
        //uc.setRequestProperty("Proxy-Authorization", "Basic " + encoded);
        uc.connect();

        if (true)
            return;

        System.out.println("sendMail()...");
        Properties props = new Properties();
        props.put("mail.smtp.host", "smtp.gmail.com");
        props.put("mail.smtp.port", "465");

        // props.put("mail.smtp.auth", "true");

        Session session = Session.getDefaultInstance(props, null);
        session.setDebug(false);
        MimeMessage message = new MimeMessage(session);
        message.setFrom(new InternetAddress("rafaelgramajo@gmail.com"));

        message.addRecipient(Message.RecipientType.TO, new InternetAddress("rafaelgramajo@gmail.com"));

        message.setSubject("subject");

        MimeBodyPart messageBodyPart = new MimeBodyPart();
        messageBodyPart.setText("bodys");

        Multipart multipart = new MimeMultipart();
        multipart.addBodyPart(messageBodyPart);

        message.setContent(multipart, "text/plain");

        Transport transport = session.getTransport("smtp");

        transport.connect("smtp.gmail.com", 465, "rafaelgramajo@gmail.com", "agdmbcchnmm");
        Transport.send(message);
    }
}
